# DBcon.py
from db_connector import DBConnection
from Services.data_generator import PurchaseExchangeDataGenerator
from data_inserter import DataInserter


def main():
    # 配置数据库连接
    db_config = {
        "host": "localhost",
        "user": "your_username",
        "password": "your_password",
        "database": "your_database",
        "port": 3306
    }

    # 生成100条数据
    generator = PurchaseExchangeDataGenerator()
    records = generator.generate_batch_records(100)

    # 插入数据
    with DBConnection(**db_config) as cursor:
        success, duplicates = DataInserter.insert_records(cursor, records)
        print(f"插入成功: {success} 条, 跳过重复: {duplicates} 条")


if __name__ == "__main__":
    main()